﻿@model MvcTemplates.Model.RadioButtonList
@{   
    var count = Model.Options.Count();
    
    for( int i = 0; i < count; i++ ){
       
        var item = Model.Options.ElementAt( i );        
        var id = string.Format( "{0}_{1}", ViewData.TemplateInfo.GetFullHtmlFieldId("Value"), i );    
        var value = item.Value ?? item.Text;
        var isChecked = item.Selected || value.Equals( Model.Value.ToString() );   
       
        @Html.C( x => x.RadioButtonListRadioButtonContainer, TagRenderMode.StartTag, additionalIdAppender: i.ToString() )        
        
            @System.Web.Mvc.Html.InputExtensions.RadioButton( Html, "Value", value, isChecked, ViewData.ModelMetadata.MergeAttributes<HtmlAttributesAttribute>( new { @class = Html.GetProfile().RadioButtonListClasses, id = id } ) )               
            <label for="@id">@item.Text</label>
    
        @Html.C( x => x.RadioButtonListRadioButtonContainer, TagRenderMode.EndTag )
    }
}